home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Programming / SPIM Folder / Sources / lex_yy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-04  |  36.2 KB  |  1,483 lines  |  [TEXT/ttxt]

  1. /* A lexical scanner generated by flex */
  2.  
  3. /* scanner skeleton version:
  4.  * $Header: /usr/fsys/odin/a/vern/flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36 vern Exp $
  5.  */
  6.  
  7. #define FLEX_SCANNER
  8.  
  9. #include <stdio.h>
  10. #ifdef WIN32
  11. #include <io.h>
  12. #endif
  13.  
  14. /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
  15. #ifdef c_plusplus
  16. #ifndef __cplusplus
  17. #define __cplusplus
  18. #endif
  19. #endif
  20.  
  21.  
  22. #ifdef __cplusplus
  23.  
  24. #include <stdlib.h>
  25. #include <osfcn.h>
  26.  
  27. /* use prototypes in function declarations */
  28. #define YY_USE_PROTOS
  29.  
  30. /* the "const" storage-class-modifier is valid */
  31. #define YY_USE_CONST
  32.  
  33. #else    /* ! __cplusplus */
  34.  
  35. #ifdef __STDC__
  36.  
  37. #ifdef __GNUC__
  38. #include <stddef.h>
  39. void *malloc( size_t );
  40. void free( void* );
  41. #else
  42. #include <stdlib.h>
  43. #endif    /* __GNUC__ */
  44.  
  45. #define YY_USE_PROTOS
  46. #define YY_USE_CONST
  47.  
  48. #endif    /* __STDC__ */
  49. #endif    /* ! __cplusplus */
  50.  
  51.  
  52. #ifdef __TURBOC__
  53. #define YY_USE_CONST
  54. #endif
  55.  
  56.  
  57. #ifndef YY_USE_CONST
  58. #define const
  59. #endif
  60.  
  61.  
  62. #ifdef YY_USE_PROTOS
  63. #define YY_PROTO(proto) proto
  64. #else
  65. #define YY_PROTO(proto) ()
  66. #endif
  67.  
  68.  
  69. /* amount of stuff to slurp up with each read */
  70. #ifndef YY_READ_BUF_SIZE
  71. #define YY_READ_BUF_SIZE 8192
  72. #endif
  73.  
  74. /* returned upon end-of-file */
  75. #define YY_END_TOK 0
  76.  
  77. /* copy whatever the last rule matched to the standard output */
  78.  
  79. /* cast to (char *) is because for 8-bit chars, yytext is (unsigned char *) */
  80. /* this used to be an fputs(), but since the string might contain NUL's,
  81.  * we now use fwrite()
  82.  */
  83. #define ECHO (void) fwrite( (char *) yytext, yyleng, 1, yyout )
  84.  
  85. /* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  86.  * is returned in "result".
  87.  */
  88. #define YY_INPUT(buf,result,max_size) \
  89.     if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
  90.         YY_FATAL_ERROR( "read() in flex scanner failed" );
  91. #define YY_NULL 0
  92.  
  93. /* no semi-colon after return; correct usage is to write "yyterminate();" -
  94.  * we don't want an extra ';' after the "return" because that will cause
  95.  * some compilers to complain about unreachable statements.
  96.  */
  97. #define yyterminate() return ( YY_NULL )
  98.  
  99. /* report a fatal error */
  100.  
  101. /* The funky do-while is used to turn this macro definition into
  102.  * a single C statement (which needs a semi-colon terminator).
  103.  * This avoids problems with code like:
  104.  *
  105.  *     if ( something_happens )
  106.  *        YY_FATAL_ERROR( "oops, the something happened" );
  107.  *    else
  108.  *        everything_okay();
  109.  *
  110.  * Prior to using the do-while the compiler would get upset at the
  111.  * "else" because it interpreted the "if" statement as being all
  112.  * done when it reached the ';' after the YY_FATAL_ERROR() call.
  113.  */
  114.  
  115. #define YY_FATAL_ERROR(msg) fatal_error(msg)
  116.  
  117. #if 0
  118. #define YY_FATAL_ERROR(msg) \
  119.     do \
  120.         { \
  121.         (void) fputs( msg, stderr ); \
  122.         (void) putc( '\n', stderr ); \
  123.         exit( 1 ); \
  124.         } \
  125.     while ( 0 )
  126. #endif
  127.  
  128. /* default yywrap function - always treat EOF as an EOF */
  129. #define yywrap() 1
  130.  
  131. /* enter a start condition.  This macro really ought to take a parameter,
  132.  * but we do it the disgusting crufty way forced on us by the ()-less
  133.  * definition of BEGIN
  134.  */
  135. #define BEGIN yy_start = 1 + 2 *
  136.  
  137. /* action number for EOF rule of a given start state */
  138. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  139.  
  140. /* special action meaning "start processing a new file" */
  141. #define YY_NEW_FILE \
  142.     do \
  143.         { \
  144.         yy_init_buffer( yy_current_buffer, yyin ); \
  145.         yy_load_buffer_state(); \
  146.         } \
  147.     while ( 0 )
  148.  
  149. /* default declaration of generated scanner - a define so the user can
  150.  * easily add parameters
  151.  */
  152. #define YY_DECL int yylex YY_PROTO(( void )) 
  153.  
  154. /* code executed at the end of each rule */
  155. #define YY_BREAK break;
  156.  
  157. #define YY_END_OF_BUFFER_CHAR 0
  158.  
  159. #ifndef YY_BUF_SIZE
  160. #define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
  161. #endif
  162.  
  163. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  164.  
  165. #define YY_CHAR unsigned char
  166. # line 1 "scanner.l"
  167. #define INITIAL 0
  168. # line 2 "scanner.l"
  169. /* SPIM S20 MIPS simulator.
  170.    Lexical scanner.
  171.    Copyright (C) 1990 by James Larus (larus@cs.wisc.edu).
  172.  
  173.    SPIM is free software; you can redistribute it and/or modify it
  174.    under the terms of the GNU General Public License as published by the
  175.    Free Software Foundation; either version 1, or (at your option) any
  176.    later version.
  177.  
  178.    SPIM is distributed in the hope that it will be useful, but WITHOUT
  179.    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  180.    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  181.    for more details.
  182.  
  183.    You should have received a copy of the GNU General Public License
  184.    along with GNU CC; see the file COPYING.  If not, write to James R.
  185.    Larus, Computer Sciences Department, University of Wisconsin--Madison,
  186.    1210 West Dayton Street, Madison, WI 53706, USA or to the Free
  187.    Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  188.  
  189.  
  190. /* $Header: /var/home/cs354/.spim/RCS/scanner.l,v 1.5 1992/10/12 11:41:52 cs354 Exp $
  191. */
  192.  
  193.  
  194. #include "y_tab.h"
  195. #include "spim.h"
  196. #include "inst.h"
  197. #include "mem.h"
  198.  
  199. #ifndef YY_CHAR
  200. #define YY_CHAR char
  201. #endif
  202.  
  203.  
  204.  
  205. /* YACC parser variable that holds value of token. */
  206.  
  207. extern int yylval;
  208.  
  209.  
  210. /* Track which line we are reading and where it began in the buffer. */
  211.  
  212. int line_no = 1;
  213.  
  214. static YY_CHAR *line_start = NULL;
  215.  
  216. extern unsigned int last_inst_addr;
  217.  
  218. static double scan_float;    /* Where FP values are kept */
  219.  
  220. int y_str_length;        /* Length of Y_STR */
  221.  
  222.  
  223. /* Local functions: */
  224.  
  225. static int check_keyword (char *, int);
  226. static YY_CHAR *copy_str (YY_CHAR *, int);
  227.  
  228. # line 65 "scanner.l"
  229.  
  230. /* done after the current pattern has been matched and before the
  231.  * corresponding action - sets up yytext
  232.  */
  233. #define YY_DO_BEFORE_ACTION \
  234.     yytext = yy_bp; \
  235.     yyleng = yy_cp - yy_bp; \
  236.     yy_hold_char = *yy_cp; \
  237.     *yy_cp = '\0'; \
  238.     yy_c_buf_p = yy_cp;
  239.  
  240. #define EOB_ACT_CONTINUE_SCAN 0
  241. #define EOB_ACT_END_OF_FILE 1
  242. #define EOB_ACT_LAST_MATCH 2
  243.  
  244. /* return all but the first 'n' matched characters back to the input stream */
  245. #define yyless(n) \
  246.     do \
  247.         { \
  248.         /* undo effects of setting up yytext */ \
  249.         *yy_cp = yy_hold_char; \
  250.         yy_c_buf_p = yy_cp = yy_bp + n; \
  251.         YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  252.         } \
  253.     while ( 0 )
  254.  
  255. #define unput(c) yyunput( c, yytext )
  256.  
  257.  
  258. struct yy_buffer_state
  259.     {
  260.     FILE *yy_input_file;
  261.  
  262.     YY_CHAR *yy_ch_buf;        /* input buffer */
  263.     YY_CHAR *yy_buf_pos;    /* current position in input buffer */
  264.  
  265.     /* size of input buffer in bytes, not including room for EOB characters*/
  266.     int yy_buf_size;    
  267.  
  268.     /* number of characters read into yy_ch_buf, not including EOB characters */
  269.     int yy_n_chars;
  270.  
  271.     int yy_eof_status;        /* whether we've seen an EOF on this buffer */
  272. #define EOF_NOT_SEEN 0
  273.     /* "pending" happens when the EOF has been seen but there's still
  274.      * some text process
  275.      */
  276. #define EOF_PENDING 1
  277. #define EOF_DONE 2
  278.     };
  279.  
  280. static YY_BUFFER_STATE yy_current_buffer;
  281.  
  282. /* we provide macros for accessing buffer states in case in the
  283.  * future we want to put the buffer states in a more general
  284.  * "scanner state"
  285.  */
  286. #define YY_CURRENT_BUFFER yy_current_buffer
  287.  
  288.  
  289. /* yy_hold_char holds the character lost when yytext is formed */
  290. static YY_CHAR yy_hold_char;
  291.  
  292. static int yy_n_chars;        /* number of characters read into yy_ch_buf */
  293.  
  294.  
  295.  
  296. #ifndef YY_USER_ACTION
  297. #define YY_USER_ACTION
  298. #endif
  299.  
  300. #ifndef YY_USER_INIT
  301. #define YY_USER_INIT
  302. #endif
  303.  
  304. extern YY_CHAR *yytext;
  305. extern int yyleng;
  306. extern FILE *yyin, *yyout;
  307.  
  308. YY_CHAR *yytext;
  309. int yyleng;
  310.  
  311. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  312.  
  313. #define YY_END_OF_BUFFER 19
  314. typedef int yy_state_type;
  315. static const short int yy_accept[47] =
  316.     {   0,
  317.         0,    0,   19,   17,    1,    2,   17,    9,   17,   17,
  318.        10,   10,   13,   10,    7,    3,    4,   14,   11,   12,
  319.         0,   15,    0,    9,    8,    0,   16,    0,    0,    3,
  320.         4,    7,    6,    3,    0,    4,   15,   16,    3,    4,
  321.         6,    6,    6,    5,    6,    0
  322.     } ;
  323.  
  324. static const YY_CHAR yy_ec[256] =
  325.     {   0,
  326.         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
  327.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  328.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  329.         1,    2,    1,    4,    5,    6,    1,    1,    7,    8,
  330.         8,    1,    9,   10,   11,   12,    1,   13,   14,   14,
  331.        14,   14,   14,   14,   14,   15,   15,    8,    1,    1,
  332.         1,    1,   16,    1,   17,   17,   17,   17,   17,   17,
  333.        18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
  334.        18,   18,   18,   18,   18,   18,   18,   18,   18,   18,
  335.        19,   20,   21,    1,   18,    1,   17,   17,   17,   17,
  336.  
  337.        22,   17,   18,   18,   18,   18,   18,   18,   18,   18,
  338.        18,   18,   18,   18,   18,   18,   18,   18,   18,   23,
  339.        18,   18,    1,    1,    1,    1,    1,    1,    1,    1,
  340.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  341.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  342.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  343.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  344.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  345.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  346.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  347.  
  348.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  349.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  350.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  351.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  352.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  353.         1,    1,    1,    1,    1
  354.     } ;
  355.  
  356. static const YY_CHAR yy_meta[24] =
  357.     {   0,
  358.         1,    1,    2,    1,    1,    3,    1,    1,    4,    1,
  359.         4,    5,    6,    6,    6,    1,    7,    8,    1,    1,
  360.         1,    7,    8
  361.     } ;
  362.  
  363. static const short int yy_base[57] =
  364.     {   0,
  365.         0,    0,   90,  118,  118,  118,   20,    0,    0,   18,
  366.       118,   13,  118,   16,    0,   29,   70,  118,  118,  118,
  367.        28,  118,   29,    0,    0,   27,  118,   30,   53,   22,
  368.        51,    0,   44,   39,    0,   48,   41,   44,   23,   27,
  369.        54,    0,   45,    0,   57,  118,   72,   80,   86,   94,
  370.        98,  102,  104,  106,  107,  111
  371.     } ;
  372.  
  373. static const short int yy_def[57] =
  374.     {   0,
  375.        46,    1,   46,   46,   46,   46,   47,   48,   49,   50,
  376.        46,   46,   46,   46,   51,   46,   52,   46,   46,   46,
  377.        47,   46,   47,   48,   49,   50,   46,   50,   53,   16,
  378.        54,   51,   46,   16,   55,   52,   47,   50,   30,   54,
  379.        46,   33,   56,   55,   46,    0,   46,   46,   46,   46,
  380.        46,   46,   46,   46,   46,   46
  381.     } ;
  382.  
  383. static const short int yy_nxt[142] =
  384.     {   0,
  385.         4,    5,    6,    7,    8,    9,   10,   11,   12,   13,
  386.        14,   15,   16,   17,   17,   18,   15,   15,   19,    4,
  387.        20,   15,   15,   22,   27,   29,   29,   29,   30,   31,
  388.        31,   22,   37,   27,   39,   39,   38,   28,   33,   23,
  389.        33,   34,   34,   29,   22,   46,   28,   23,   23,   28,
  390.        27,   35,   41,   41,   41,   41,   42,   42,   42,   33,
  391.        23,   46,   33,   28,   33,   43,   45,   45,   45,   45,
  392.        45,   45,   21,   21,   21,   21,   21,   21,   21,   21,
  393.        24,   33,   24,   24,   24,   24,   24,   24,   25,   46,
  394.        25,   25,   25,   25,   26,   26,   26,   26,   26,   26,
  395.  
  396.        26,   26,   32,   32,   32,   32,   36,   36,   29,   29,
  397.        40,   40,   44,   44,   45,   46,   45,    3,   46,   46,
  398.        46,   46,   46,   46,   46,   46,   46,   46,   46,   46,
  399.        46,   46,   46,   46,   46,   46,   46,   46,   46,   46,
  400.        46
  401.     } ;
  402.  
  403. static const short int yy_chk[142] =
  404.     {   0,
  405.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  406.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  407.         1,    1,    1,    7,   10,   12,   12,   12,   14,   14,
  408.        14,   21,   23,   26,   30,   30,   28,   10,   40,    7,
  409.        16,   16,   16,   16,   37,   39,   26,   21,   23,   28,
  410.        38,   16,   33,   43,   33,   43,   33,   33,   33,   36,
  411.        37,   34,   31,   38,   29,   33,   41,   41,   41,   45,
  412.        45,   45,   47,   47,   47,   47,   47,   47,   47,   47,
  413.        48,   17,   48,   48,   48,   48,   48,   48,   49,    3,
  414.        49,   49,   49,   49,   50,   50,   50,   50,   50,   50,
  415.  
  416.        50,   50,   51,   51,   51,   51,   52,   52,   53,   53,
  417.        54,   54,   55,   55,   56,    0,   56,   46,   46,   46,
  418.        46,   46,   46,   46,   46,   46,   46,   46,   46,   46,
  419.        46,   46,   46,   46,   46,   46,   46,   46,   46,   46,
  420.        46
  421.     } ;
  422.  
  423. static yy_state_type yy_last_accepting_state;
  424. static YY_CHAR *yy_last_accepting_cpos;
  425.  
  426. /* the intent behind this definition is that it'll catch
  427.  * any uses of REJECT which flex missed
  428.  */
  429. #define REJECT reject_used_but_not_detected
  430. #define yymore() yymore_used_but_not_detected
  431. #define YY_MORE_ADJ 0
  432.  
  433. /* these variables are all declared out here so that section 3 code can
  434.  * manipulate them
  435.  */
  436. /* points to current character in buffer */
  437. static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
  438. static int yy_init = 1;        /* whether we need to initialize */
  439. static int yy_start = 0;    /* start state number */
  440.  
  441. /* flag which is used to allow yywrap()'s to do buffer switches
  442.  * instead of setting up a fresh yyin.  A bit of a hack ...
  443.  */
  444. static int yy_did_buffer_switch_on_eof;
  445.  
  446. static yy_state_type yy_get_previous_state YY_PROTO(( void ));
  447. static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
  448. static int yy_get_next_buffer YY_PROTO(( void ));
  449. static void yyunput YY_PROTO(( YY_CHAR c, YY_CHAR *buf_ptr ));
  450. void yyrestart YY_PROTO(( FILE *input_file ));
  451. void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
  452. void yy_load_buffer_state YY_PROTO(( void ));
  453. YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
  454. void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
  455. void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
  456.  
  457. #define yy_new_buffer yy_create_buffer
  458.  
  459. #ifdef __cplusplus
  460. static int yyinput YY_PROTO(( void ));
  461. #else
  462. static int input YY_PROTO(( void ));
  463. #endif
  464.  
  465. YY_DECL
  466.     {
  467.     register yy_state_type yy_current_state;
  468.     register YY_CHAR *yy_cp, *yy_bp;
  469.     register int yy_act;
  470.  
  471.     char *temp_str;
  472.  
  473.  
  474.     if ( yy_init )
  475.     {
  476.     YY_USER_INIT;
  477.  
  478.     if ( ! yy_start )
  479.         yy_start = 1;    /* first start state */
  480.  
  481.     if ( ! yyin )
  482.         yyin = stdin;
  483.  
  484.     if ( ! yyout )
  485.         yyout = stdout;
  486.  
  487.     if ( yy_current_buffer )
  488.         yy_init_buffer( yy_current_buffer, yyin );
  489.     else
  490.         yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  491.  
  492.     yy_load_buffer_state();
  493.  
  494.     yy_init = 0;
  495.     }
  496.  
  497.     while ( 1 )        /* loops until end-of-file is reached */
  498.     {
  499.     yy_cp = yy_c_buf_p;
  500.  
  501.     /* support of yytext */
  502.     *yy_cp = yy_hold_char;
  503.  
  504.     /* yy_bp points to the position in yy_ch_buf of the start of the
  505.      * current run.
  506.      */
  507.     yy_bp = yy_cp;
  508.  
  509.     yy_current_state = yy_start;
  510. yy_match:
  511.     do
  512.         {
  513.         register YY_CHAR yy_c = yy_ec[*yy_cp];
  514.         if ( yy_accept[yy_current_state] )
  515.         {
  516.         yy_last_accepting_state = yy_current_state;
  517.         yy_last_accepting_cpos = yy_cp;
  518.         }
  519.         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  520.         {
  521.         yy_current_state = yy_def[yy_current_state];
  522.         if ( yy_current_state >= 47 )
  523.             yy_c = yy_meta[yy_c];
  524.         }
  525.         yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  526.         ++yy_cp;
  527.         }
  528.     while ( yy_base[yy_current_state] != 118 );
  529.  
  530. yy_find_action:
  531.     yy_act = yy_accept[yy_current_state];
  532.  
  533.     YY_DO_BEFORE_ACTION;
  534.     YY_USER_ACTION;
  535.  
  536. do_action:    /* this label is used only to access EOF actions */
  537.  
  538.  
  539.     switch ( yy_act )
  540.         {
  541.         case 0: /* must backtrack */
  542.         /* undo the effects of YY_DO_BEFORE_ACTION */
  543.         *yy_cp = yy_hold_char;
  544.         yy_cp = yy_last_accepting_cpos;
  545.         yy_current_state = yy_last_accepting_state;
  546.         goto yy_find_action;
  547.  
  548. case 1:
  549. # line 67 "scanner.l"
  550. {if (line_start == NULL) line_start = yytext;}
  551.     YY_BREAK
  552. case 2:
  553. # line 70 "scanner.l"
  554. {line_no += 1;
  555.              return (Y_NL);}
  556.     YY_BREAK
  557. case 3:
  558. # line 74 "scanner.l"
  559. {/*int x;
  560.                sscanf (yytext, "%o", &yylval);*/
  561.              yylval = atoi ((char *) yytext);
  562.              if (line_start == NULL) line_start = yytext;
  563.              return (Y_INT);}
  564.     YY_BREAK
  565. case 4:
  566. # line 80 "scanner.l"
  567. {/*int x;
  568.                sscanf (yytext, "%d", &yylval);*/
  569.              yylval = atoi ((char *) yytext);
  570.              if (line_start == NULL) line_start = yytext;
  571.              return (Y_INT);}
  572.     YY_BREAK
  573. case 5:
  574. # line 87 "scanner.l"
  575. {if (*yytext == '-')
  576.                 {
  577.                   sscanf((char *) yytext+3, "%lx", &yylval);
  578.                   yylval = -yylval;
  579.                 }
  580.               else
  581.                 {
  582.                   sscanf((char *) yytext+2, "%lx", &yylval);
  583.                 }
  584.  
  585.               if (line_start == NULL) line_start = yytext;
  586.               return (Y_INT);}
  587.     YY_BREAK
  588. case 6:
  589. # line 101 "scanner.l"
  590. {
  591.              scan_float = atof ((char *) yytext);
  592.              yylval = (int) &scan_float;
  593.              if (line_start == NULL) line_start = yytext;
  594.              return (Y_FP);}
  595.     YY_BREAK
  596. case 7:
  597. # line 108 "scanner.l"
  598. {int token = check_keyword ((char *) yytext, !bare_machine);
  599.                 if (line_start == NULL) line_start = yytext;
  600.                 if (token != 0)
  601.                   {
  602.                 yylval = token;
  603.                 line_start = yytext;
  604.                 return (token);
  605.                   }
  606.                 temp_str = malloc (strlen ((char *) yytext)+1);
  607.                 if ( !temp_str )
  608.                     YY_FATAL_ERROR("Scanner ran out of memory copying a string.");
  609.                 yylval = (int) strcpy (temp_str,
  610.                            (char *) yytext);
  611.                 return (Y_ID);}
  612.     YY_BREAK
  613. case 8:
  614. # line 121 "scanner.l"
  615. {int reg_no = register_name_to_number ((char *) yytext + 1);
  616.              if (line_start == NULL) line_start = yytext;
  617.              if (reg_no != -1
  618.                  && *(yytext + 1) == 'f' && *(yytext + 2) != 'p')
  619.                {
  620.                  yylval = reg_no;
  621.                  return (Y_FP_REG);
  622.                }
  623.              else if (reg_no < 0 || reg_no > 31)
  624.                {
  625.                 temp_str = malloc (strlen ((char *) yytext)+1);
  626.                 if ( !temp_str )
  627.                     YY_FATAL_ERROR("Scanner ran out of memory copying a string.");
  628.                  yylval = (int) strcpy (temp_str,
  629.                             (char *) yytext);
  630.                  return (Y_ID);
  631.                }
  632.              else
  633.                {
  634.                  yylval =reg_no;
  635.                  return (Y_REG);
  636.                }}
  637.     YY_BREAK
  638. case 9:
  639. # line 142 "scanner.l"
  640. {if (line_start == NULL) line_start = yytext;}
  641.     YY_BREAK
  642. case 10:
  643. # line 145 "scanner.l"
  644. {if (line_start == NULL) line_start = yytext;
  645.              return (*yytext);}
  646.     YY_BREAK
  647. case 11:
  648. # line 148 "scanner.l"
  649. {if (line_start == NULL) line_start = yytext;
  650.              return (*yytext);}
  651.     YY_BREAK
  652. case 12:
  653. # line 151 "scanner.l"
  654. {if (line_start == NULL) line_start = yytext;
  655.              return (*yytext);}
  656.     YY_BREAK
  657. case 13:
  658. # line 154 "scanner.l"
  659. {if (line_start == NULL) line_start = yytext;}
  660.     YY_BREAK
  661. case 14:
  662. # line 156 "scanner.l"
  663. {if (line_start == NULL) line_start = yytext;
  664.                 temp_str = malloc (strlen ((char *) yytext)+1);
  665.                 if ( !temp_str )
  666.                     YY_FATAL_ERROR("Scanner ran out of memory copying a string.");
  667.              yylval = (int) strcpy (temp_str,
  668.                         (char *) yytext);
  669.              /* For top level */
  670.              return (Y_ID);}
  671.     YY_BREAK
  672. case 15:
  673. # line 163 "scanner.l"
  674. {if (line_start == NULL) line_start = yytext;
  675.              yylval = (int) copy_str (yytext + 1, 1);
  676.              return (Y_STR);}
  677.     YY_BREAK
  678. case 16:
  679. # line 167 "scanner.l"
  680. {if (line_start == NULL) line_start = yytext;
  681.              yylval = (int) copy_str (yytext + 1, 1);
  682.              return (Y_STR);}
  683.     YY_BREAK
  684. case 17:
  685. # line 171 "scanner.l"
  686. {if (line_start == NULL) line_start = yytext;
  687.              yyerror ("Unknown character");}
  688.     YY_BREAK
  689. case 18:
  690. # line 174 "scanner.l"
  691. ECHO;
  692.     YY_BREAK
  693. case YY_STATE_EOF(INITIAL):
  694.     yyterminate();
  695.  
  696.         case YY_END_OF_BUFFER:
  697.         {
  698.         /* amount of text matched not including the EOB char */
  699.         int yy_amount_of_matched_text = yy_cp - yytext - 1;
  700.  
  701.         /* undo the effects of YY_DO_BEFORE_ACTION */
  702.         *yy_cp = yy_hold_char;
  703.  
  704.         /* note that here we test for yy_c_buf_p "<=" to the position
  705.          * of the first EOB in the buffer, since yy_c_buf_p will
  706.          * already have been incremented past the NUL character
  707.          * (since all states make transitions on EOB to the end-
  708.          * of-buffer state).  Contrast this with the test in yyinput().
  709.          */
  710.         if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  711.             /* this was really a NUL */
  712.             {
  713.             yy_state_type yy_next_state;
  714.  
  715.             yy_c_buf_p = yytext + yy_amount_of_matched_text;
  716.  
  717.             yy_current_state = yy_get_previous_state();
  718.  
  719.             /* okay, we're now positioned to make the
  720.              * NUL transition.  We couldn't have
  721.              * yy_get_previous_state() go ahead and do it
  722.              * for us because it doesn't know how to deal
  723.              * with the possibility of jamming (and we
  724.              * don't want to build jamming into it because
  725.              * then it will run more slowly)
  726.              */
  727.  
  728.             yy_next_state = yy_try_NUL_trans( yy_current_state );
  729.  
  730.             yy_bp = yytext + YY_MORE_ADJ;
  731.  
  732.             if ( yy_next_state )
  733.             {
  734.             /* consume the NUL */
  735.             yy_cp = ++yy_c_buf_p;
  736.             yy_current_state = yy_next_state;
  737.             goto yy_match;
  738.             }
  739.  
  740.             else
  741.             {
  742.             goto yy_find_action;
  743.             }
  744.             }
  745.  
  746.         else switch ( yy_get_next_buffer() )
  747.             {
  748.             case EOB_ACT_END_OF_FILE:
  749.             {
  750.             yy_did_buffer_switch_on_eof = 0;
  751.  
  752.             if ( yywrap() )
  753.                 {
  754.                 /* note: because we've taken care in
  755.                  * yy_get_next_buffer() to have set up yytext,
  756.                  * we can now set up yy_c_buf_p so that if some
  757.                  * total hoser (like flex itself) wants
  758.                  * to call the scanner after we return the
  759.                  * YY_NULL, it'll still work - another YY_NULL
  760.                  * will get returned.
  761.                  */
  762.                 yy_c_buf_p = yytext + YY_MORE_ADJ;
  763.  
  764.                 yy_act = YY_STATE_EOF((yy_start - 1) / 2);
  765.                 goto do_action;
  766.                 }
  767.  
  768.             else
  769.                 {
  770.                 if ( ! yy_did_buffer_switch_on_eof )
  771.                 YY_NEW_FILE;
  772.                 }
  773.             }
  774.             break;
  775.  
  776.             case EOB_ACT_CONTINUE_SCAN:
  777.             yy_c_buf_p = yytext + yy_amount_of_matched_text;
  778.  
  779.             yy_current_state = yy_get_previous_state();
  780.  
  781.             yy_cp = yy_c_buf_p;
  782.             yy_bp = yytext + YY_MORE_ADJ;
  783.             goto yy_match;
  784.  
  785.             case EOB_ACT_LAST_MATCH:
  786.             yy_c_buf_p =
  787.                 &yy_current_buffer->yy_ch_buf[yy_n_chars];
  788.  
  789.             yy_current_state = yy_get_previous_state();
  790.  
  791.             yy_cp = yy_c_buf_p;
  792.             yy_bp = yytext + YY_MORE_ADJ;
  793.             goto yy_find_action;
  794.             }
  795.         break;
  796.         }
  797.  
  798.         default:
  799. #ifdef FLEX_DEBUG
  800.         printf( "action # %d\n", yy_act );
  801. #endif
  802.         YY_FATAL_ERROR(
  803.             "fatal flex scanner internal error--no action found" );
  804.         }
  805.     }
  806.     }
  807.  
  808.  
  809. /* yy_get_next_buffer - try to read in a new buffer
  810.  *
  811.  * synopsis
  812.  *     int yy_get_next_buffer();
  813.  *     
  814.  * returns a code representing an action
  815.  *     EOB_ACT_LAST_MATCH - 
  816.  *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  817.  *     EOB_ACT_END_OF_FILE - end of file
  818.  */
  819.  
  820. static int yy_get_next_buffer()
  821.  
  822.     {
  823.     register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
  824.     register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
  825.     register int number_to_move, i;
  826.     int ret_val;
  827.  
  828.     if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  829.     YY_FATAL_ERROR(
  830.         "fatal flex scanner internal error--end of buffer missed" );
  831.  
  832.     /* try to read more data */
  833.  
  834.     /* first move last chars to start of buffer */
  835.     number_to_move = yy_c_buf_p - yytext;
  836.  
  837.     for ( i = 0; i < number_to_move; ++i )
  838.     *(dest++) = *(source++);
  839.  
  840.     if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
  841.     /* don't do the read, it's not guaranteed to return an EOF,
  842.      * just force an EOF
  843.      */
  844.     yy_n_chars = 0;
  845.  
  846.     else
  847.     {
  848.     int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
  849.  
  850.     if ( num_to_read > YY_READ_BUF_SIZE )
  851.         num_to_read = YY_READ_BUF_SIZE;
  852.  
  853.     else if ( num_to_read <= 0 )
  854.         YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
  855.  
  856.     /* read in more data */
  857.     YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  858.           yy_n_chars, num_to_read );
  859.     }
  860.  
  861.     if ( yy_n_chars == 0 )
  862.     {
  863.     if ( number_to_move == 1 )
  864.         {
  865.         ret_val = EOB_ACT_END_OF_FILE;
  866.         yy_current_buffer->yy_eof_status = EOF_DONE;
  867.         }
  868.  
  869.     else
  870.         {
  871.         ret_val = EOB_ACT_LAST_MATCH;
  872.         yy_current_buffer->yy_eof_status = EOF_PENDING;
  873.         }
  874.     }
  875.  
  876.     else
  877.     ret_val = EOB_ACT_CONTINUE_SCAN;
  878.  
  879.     yy_n_chars += number_to_move;
  880.     yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  881.     yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  882.  
  883.     /* yytext begins at the second character in yy_ch_buf; the first
  884.      * character is the one which preceded it before reading in the latest
  885.      * buffer; it needs to be kept around in case it's a newline, so
  886.      * yy_get_previous_state() will have with '^' rules active
  887.      */
  888.  
  889.     yytext = &yy_current_buffer->yy_ch_buf[1];
  890.  
  891.     return ( ret_val );
  892.     }
  893.  
  894.  
  895. /* yy_get_previous_state - get the state just before the EOB char was reached
  896.  *
  897.  * synopsis
  898.  *     yy_state_type yy_get_previous_state();
  899.  */
  900.  
  901. static yy_state_type yy_get_previous_state()
  902.  
  903.     {
  904.     register yy_state_type yy_current_state;
  905.     register YY_CHAR *yy_cp;
  906.  
  907.     yy_current_state = yy_start;
  908.  
  909.     for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  910.     {
  911.     register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
  912.     if ( yy_accept[yy_current_state] )
  913.         {
  914.         yy_last_accepting_state = yy_current_state;
  915.         yy_last_accepting_cpos = yy_cp;
  916.         }
  917.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  918.         {
  919.         yy_current_state = yy_def[yy_current_state];
  920.         if ( yy_current_state >= 47 )
  921.         yy_c = yy_meta[yy_c];
  922.         }
  923.     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  924.     }
  925.  
  926.     return ( yy_current_state );
  927.     }
  928.  
  929.  
  930. /* yy_try_NUL_trans - try to make a transition on the NUL character
  931.  *
  932.  * synopsis
  933.  *     next_state = yy_try_NUL_trans( current_state );
  934.  */
  935.  
  936. #ifdef YY_USE_PROTOS
  937. static yy_state_type yy_try_NUL_trans( register yy_state_type yy_current_state )
  938. #else
  939. static yy_state_type yy_try_NUL_trans( yy_current_state )
  940. register yy_state_type yy_current_state;
  941. #endif
  942.  
  943.     {
  944.     register int yy_is_jam;
  945.     register YY_CHAR *yy_cp = yy_c_buf_p;
  946.  
  947.     register YY_CHAR yy_c = 1;
  948.     if ( yy_accept[yy_current_state] )
  949.     {
  950.     yy_last_accepting_state = yy_current_state;
  951.     yy_last_accepting_cpos = yy_cp;
  952.     }
  953.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  954.     {
  955.     yy_current_state = yy_def[yy_current_state];
  956.     if ( yy_current_state >= 47 )
  957.         yy_c = yy_meta[yy_c];
  958.     }
  959.     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  960.     yy_is_jam = (yy_base[yy_current_state] == 118);
  961.  
  962.     return ( yy_is_jam ? 0 : yy_current_state );
  963.     }
  964.  
  965.  
  966. #ifdef YY_USE_PROTOS
  967. static void yyunput( YY_CHAR c, register YY_CHAR *yy_bp )
  968. #else
  969. static void yyunput( c, yy_bp )
  970. YY_CHAR c;
  971. register YY_CHAR *yy_bp;
  972. #endif
  973.  
  974.     {
  975.     register YY_CHAR *yy_cp = yy_c_buf_p;
  976.  
  977.     /* undo effects of setting up yytext */
  978.     *yy_cp = yy_hold_char;
  979.  
  980.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  981.     { /* need to shift things up to make room */
  982.     register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  983.     register YY_CHAR *dest =
  984.         &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
  985.     register YY_CHAR *source =
  986.         &yy_current_buffer->yy_ch_buf[number_to_move];
  987.  
  988.     while ( source > yy_current_buffer->yy_ch_buf )
  989.         *--dest = *--source;
  990.  
  991.     yy_cp += dest - source;
  992.     yy_bp += dest - source;
  993.     yy_n_chars = yy_current_buffer->yy_buf_size;
  994.  
  995.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  996.         YY_FATAL_ERROR( "flex scanner push-back overflow" );
  997.     }
  998.  
  999.     if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  1000.     yy_cp[-2] = '\n';
  1001.  
  1002.     *--yy_cp = c;
  1003.  
  1004.     /* note: the formal parameter *must* be called "yy_bp" for this
  1005.      *       macro to now work correctly
  1006.      */
  1007.     YY_DO_BEFORE_ACTION; /* set up yytext again */
  1008.     }
  1009.  
  1010.  
  1011. #ifdef __cplusplus
  1012. static int yyinput()
  1013. #else
  1014. static int input()
  1015. #endif
  1016.  
  1017.     {
  1018.     int c;
  1019.     YY_CHAR *yy_cp = yy_c_buf_p;
  1020.  
  1021.     *yy_cp = yy_hold_char;
  1022.  
  1023.     if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  1024.     {
  1025.     /* yy_c_buf_p now points to the character we want to return.
  1026.      * If this occurs *before* the EOB characters, then it's a
  1027.      * valid NUL; if not, then we've hit the end of the buffer.
  1028.      */
  1029.     if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  1030.         /* this was really a NUL */
  1031.         *yy_c_buf_p = '\0';
  1032.  
  1033.     else
  1034.         { /* need more input */
  1035.         yytext = yy_c_buf_p;
  1036.         ++yy_c_buf_p;
  1037.  
  1038.         switch ( yy_get_next_buffer() )
  1039.         {
  1040.         case EOB_ACT_END_OF_FILE:
  1041.             {
  1042.             if ( yywrap() )
  1043.             {
  1044.             yy_c_buf_p = yytext + YY_MORE_ADJ;
  1045.             return ( EOF );
  1046.             }
  1047.  
  1048.             YY_NEW_FILE;
  1049.  
  1050. #ifdef __cplusplus
  1051.             return ( yyinput() );
  1052. #else
  1053.             return ( input() );
  1054. #endif
  1055.             }
  1056.             break;
  1057.  
  1058.         case EOB_ACT_CONTINUE_SCAN:
  1059.             yy_c_buf_p = yytext + YY_MORE_ADJ;
  1060.             break;
  1061.  
  1062.         case EOB_ACT_LAST_MATCH:
  1063. #ifdef __cplusplus
  1064.             YY_FATAL_ERROR( "unexpected last match in yyinput()" );
  1065. #else
  1066.             YY_FATAL_ERROR( "unexpected last match in input()" );
  1067. #endif
  1068.         }
  1069.         }
  1070.     }
  1071.  
  1072.     c = *yy_c_buf_p;
  1073.     yy_hold_char = *++yy_c_buf_p;
  1074.  
  1075.     return ( c );
  1076.     }
  1077.  
  1078.  
  1079. #ifdef YY_USE_PROTOS
  1080. void yyrestart( FILE *input_file )
  1081. #else
  1082. void yyrestart( input_file )
  1083. FILE *input_file;
  1084. #endif
  1085.  
  1086.     {
  1087.     yy_init_buffer( yy_current_buffer, input_file );
  1088.     yy_load_buffer_state();
  1089.     }
  1090.  
  1091.  
  1092. #ifdef YY_USE_PROTOS
  1093. void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
  1094. #else
  1095. void yy_switch_to_buffer( new_buffer )
  1096. YY_BUFFER_STATE new_buffer;
  1097. #endif
  1098.  
  1099.     {
  1100.     if ( yy_current_buffer == new_buffer )
  1101.     return;
  1102.  
  1103.     if ( yy_current_buffer )
  1104.     {
  1105.     /* flush out information for old buffer */
  1106.     *yy_c_buf_p = yy_hold_char;
  1107.     yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  1108.     yy_current_buffer->yy_n_chars = yy_n_chars;
  1109.     }
  1110.  
  1111.     yy_current_buffer = new_buffer;
  1112.     yy_load_buffer_state();
  1113.  
  1114.     /* we don't actually know whether we did this switch during
  1115.      * EOF (yywrap()) processing, but the only time this flag
  1116.      * is looked at is after yywrap() is called, so it's safe
  1117.      * to go ahead and always set it.
  1118.      */
  1119.     yy_did_buffer_switch_on_eof = 1;
  1120.     }
  1121.  
  1122.  
  1123. #ifdef YY_USE_PROTOS
  1124. void yy_load_buffer_state( void )
  1125. #else
  1126. void yy_load_buffer_state()
  1127. #endif
  1128.  
  1129.     {
  1130.     yy_n_chars = yy_current_buffer->yy_n_chars;
  1131.     yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  1132.     yyin = yy_current_buffer->yy_input_file;
  1133.     yy_hold_char = *yy_c_buf_p;
  1134.     }
  1135.  
  1136.  
  1137. #ifdef YY_USE_PROTOS
  1138. YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
  1139. #else
  1140. YY_BUFFER_STATE yy_create_buffer( file, size )
  1141. FILE *file;
  1142. int size;
  1143. #endif
  1144.  
  1145.     {
  1146.     YY_BUFFER_STATE b;
  1147.  
  1148. #ifdef MACINTOSH
  1149.     b = (YY_BUFFER_STATE) NewPtr(sizeof(struct yy_buffer_state));
  1150. #else
  1151.     b = (YY_BUFFER_STATE) malloc( sizeof( struct yy_buffer_state ) );
  1152. #endif
  1153.  
  1154.     if ( ! b )
  1155.     YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1156.  
  1157.     b->yy_buf_size = size;
  1158.  
  1159.     /* yy_ch_buf has to be 2 characters longer than the size given because
  1160.      * we need to put in 2 end-of-buffer characters.
  1161.      */
  1162. #ifdef MACINTOSH
  1163.     b->yy_ch_buf = (YY_CHAR *) NewPtr( (unsigned) (b->yy_buf_size + 2) );
  1164. #else
  1165.     b->yy_ch_buf = (YY_CHAR *) malloc( (unsigned) (b->yy_buf_size + 2) );
  1166. #endif
  1167.  
  1168.     if ( ! b->yy_ch_buf )
  1169.     YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1170.  
  1171.     yy_init_buffer( b, file );
  1172.  
  1173.     return ( b );
  1174.     }
  1175.  
  1176.  
  1177. #ifdef YY_USE_PROTOS
  1178. void yy_delete_buffer( YY_BUFFER_STATE b )
  1179. #else
  1180. void yy_delete_buffer( b )
  1181. YY_BUFFER_STATE b;
  1182. #endif
  1183.  
  1184.     {
  1185.     if ( b == yy_current_buffer )
  1186.     yy_current_buffer = (YY_BUFFER_STATE) 0;
  1187.  
  1188.     free( (char *) b->yy_ch_buf );
  1189.     free( (char *) b );
  1190.     }
  1191.  
  1192.  
  1193. #ifdef YY_USE_PROTOS
  1194. void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
  1195. #else
  1196. void yy_init_buffer( b, file )
  1197. YY_BUFFER_STATE b;
  1198. FILE *file;
  1199. #endif
  1200.  
  1201.     {
  1202.     b->yy_input_file = file;
  1203.  
  1204.     /* we put in the '\n' and start reading from [1] so that an
  1205.      * initial match-at-newline will be true.
  1206.      */
  1207.  
  1208.     b->yy_ch_buf[0] = '\n';
  1209.     b->yy_n_chars = 1;
  1210.  
  1211.     /* we always need two end-of-buffer characters.  The first causes
  1212.      * a transition to the end-of-buffer state.  The second causes
  1213.      * a jam in that state.
  1214.      */
  1215.     b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  1216.     b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
  1217.  
  1218.     b->yy_buf_pos = &b->yy_ch_buf[1];
  1219.  
  1220.     b->yy_eof_status = EOF_NOT_SEEN;
  1221.     }
  1222. # line 174 "scanner.l"
  1223.  
  1224.  
  1225.  
  1226.  
  1227. void initialize_scanner (FILE *in_file)
  1228. {
  1229.   yyin = in_file;
  1230. #ifdef FLEX_SCANNER
  1231.   yy_init = 1;
  1232. #endif
  1233.   line_no = 1;
  1234.   line_start = NULL;
  1235. }
  1236.  
  1237.  
  1238. void scanner_start_line (void)
  1239. {
  1240.   if (last_inst_addr && line_start) {
  1241.       int len;
  1242.       instruction *insn;
  1243.       READ_MEM_INST(insn, last_inst_addr);
  1244.       if (insn) {
  1245.       len = strlen(line_start);
  1246.       if (NULL == (COMMENT(insn) = (char *)malloc(len+1))) {
  1247.             fatal_error("Out of memory.\n");
  1248. #if 0
  1249.           fprintf(stderr, "Out of memory.\n");
  1250.           exit(-1);
  1251. #endif
  1252.       }
  1253.       bcopy(line_start, COMMENT(insn), len+1);
  1254.       if ((COMMENT(insn))[len-1] == '\n')
  1255.           (COMMENT(insn))[len-1] = '\0';
  1256.       last_inst_addr = 0;
  1257.       SET_MEM_INST(last_inst_addr, insn);
  1258.       }
  1259.   }
  1260.   line_start = NULL;
  1261. }
  1262.  
  1263.  
  1264. #ifndef FLEX_SCANNER
  1265. /* We don't use -ll */
  1266. int yywrap () {return 1;}
  1267. #endif
  1268.  
  1269.  
  1270. /* Return a freshly-allocated copy of STRING with the last CHOP
  1271.    characters removed. */
  1272.  
  1273. static YY_CHAR *copy_str (YY_CHAR *str, int chop)
  1274. {
  1275.   register int new_len = strlen (str) - chop;
  1276.   register YY_CHAR *new_str = (YY_CHAR *) malloc (new_len + 1), *n;
  1277.  
  1278.   if ( !new_str )
  1279.     YY_FATAL_ERROR("Scanner ran out of memory in copy_str().\n");
  1280.  
  1281.   for (n = new_str; *str != '\0' && new_len > 0; new_len -= 1)
  1282.     if (*str == '\\')
  1283.       switch (*(str + 1))
  1284.     {
  1285.     case 'n':
  1286.       {
  1287.         *n ++ = '\n';
  1288.         str += 2;
  1289.         new_len -= 1;
  1290.         continue;
  1291.       }
  1292.     case 't':
  1293.       {
  1294.         *n ++ = '\t';
  1295.         str += 2;
  1296.         new_len -= 1;
  1297.         continue;
  1298.       }
  1299.     case '0':
  1300.       {
  1301.         *n ++ = '\0';
  1302.         str += 2;
  1303.         new_len -= 1;
  1304.         continue;
  1305.       }
  1306.     case '"':
  1307.       {
  1308.         *n ++ = '"';
  1309.         str += 2;
  1310.         new_len -= 1;
  1311.         continue;
  1312.       }
  1313.     case 'X':
  1314.       {
  1315.         YY_CHAR c1 = *(str + 2), c2 = *(str + 3);
  1316.         int b = 0;
  1317.  
  1318.         if ('0' <= c1 && c1 <= '9') b = c1 - '0';
  1319.         else if ('A' <= c1 && c1 <= 'F') b = c1 - 'A' + 10;
  1320.         else yyerror ("Bad character in \\X construct in string");
  1321.  
  1322.         b <<= 4;
  1323.         if ('0' <= c2 && c2 <= '9') b += c2 - '0';
  1324.         else if ('A' <= c2 && c2 <= 'F') b += c2 - 'A' + 10;
  1325.         else yyerror ("Bad character in \\X construct in string");
  1326.  
  1327.         *n ++ = (YY_CHAR) b;
  1328.         str += 4;
  1329.         new_len -= 3;
  1330.         continue;
  1331.       }
  1332.     default:
  1333.       {
  1334.         *n ++ = *str ++;
  1335.         continue;
  1336.       }
  1337.     }
  1338.     else
  1339.       *n ++ = *str ++;
  1340.  
  1341.   *n = '\0';
  1342.   y_str_length = n - new_str;
  1343.   return (new_str);
  1344. }
  1345.  
  1346.  
  1347. /* On a parse error, write out the current line and print a caret (^)
  1348.    below the point at which the error occured.    Also, reset the input
  1349.    stream to the begining of the next line. */
  1350.  
  1351. void print_erroneous_line (void)
  1352. {
  1353.   int prefix_length = yytext - line_start;
  1354.   int i, c;
  1355. #define BSIZE 1024
  1356.   YY_CHAR buffer[BSIZE], *bp = buffer;
  1357.  
  1358.   if (line_start == NULL) return;
  1359.  
  1360.   error ("      ");
  1361.   c = *(line_start + prefix_length);
  1362.   *(line_start + prefix_length) = '\0';
  1363.   sprintf(mess_buff, "%s", line_start);
  1364.   error (mess_buff);
  1365.   *(line_start + prefix_length) = c;
  1366.   sprintf(mess_buff, "%s", yytext);
  1367.   error (mess_buff);
  1368.  
  1369.   /* Flush the rest of the line. */
  1370.   if (*yytext != '\n')
  1371.     {
  1372.       int suffix_length = 0;
  1373.  
  1374.       while ((c = input ()) != '\n' && c != EOF)
  1375.     {
  1376.       *bp ++ = c;
  1377.       suffix_length += 1;
  1378.     }
  1379.       *bp = '\0';
  1380.       sprintf(mess_buff, "%s\n", buffer);
  1381.       error (mess_buff);
  1382. #ifdef FLEX_SCANNER
  1383.       if (c == '\n') unput('\n');
  1384. #endif
  1385.       line_start = NULL;
  1386.     }
  1387.  
  1388.   error ("      ");
  1389.   while (prefix_length >= 50) {
  1390.       error("                                                  ");
  1391.       prefix_length -= 50;
  1392.   }
  1393.   for (i = 0; i < prefix_length; i ++) buffer[i] = ' ';
  1394.   buffer[i] = '\0';
  1395.   sprintf(mess_buff, "%s^\n", buffer);
  1396.   error (mess_buff);
  1397. }
  1398.  
  1399.  
  1400. static inst_info keyword_tbl [] = {
  1401. #undef OP
  1402. #define OP(NAME, OPCODE, TYPE, R_OPCODE) {NAME, OPCODE, TYPE},
  1403. #include "op.h"
  1404. };
  1405.  
  1406.  
  1407. static int check_keyword (char *id, int allow_pseudo_ops)
  1408. {
  1409.   inst_info *entry =
  1410.     map_string_to_inst_info (keyword_tbl,
  1411.                  sizeof(keyword_tbl) / sizeof (inst_info),
  1412.                  id);
  1413.   if (entry == NULL)
  1414.     return (0);
  1415.   else if (!allow_pseudo_ops && entry->value2 == PSEUDO_OP)
  1416.     return (0);
  1417.   else
  1418.     return (entry->value1);
  1419. }
  1420.  
  1421.  
  1422. static inst_info register_tbl [] = {
  1423.   {"a0", 4, 0},
  1424.   {"a1", 5, 0},
  1425.   {"a2", 6, 0},
  1426.   {"a3", 7, 0},
  1427.   {"at", 1, 0},
  1428.   {"fp", 30, 0},
  1429.   {"gp", 28, 0},
  1430.   {"k0", 26, 0},
  1431.   {"k1", 27, 0},
  1432.   {"kt0", 26, 0},
  1433.   {"kt1", 27, 0},
  1434.   {"ra", 31, 0},
  1435.   {"s0", 16, 0},
  1436.   {"s1", 17, 0},
  1437.   {"s2", 18, 0},
  1438.   {"s3", 19, 0},
  1439.   {"s4", 20, 0},
  1440.   {"s5", 21, 0},
  1441.   {"s6", 22, 0},
  1442.   {"s7", 23, 0},
  1443.   {"s8", 30, 0},
  1444.   {"sp", 29, 0},
  1445.   {"t0", 8, 0},
  1446.   {"t1", 9, 0},
  1447.   {"t2", 10, 0},
  1448.   {"t3", 11, 0},
  1449.   {"t4", 12, 0},
  1450.   {"t5", 13, 0},
  1451.   {"t6", 14, 0},
  1452.   {"t7", 15, 0},
  1453.   {"t8", 24, 0},
  1454.   {"t9", 25, 0},
  1455.   {"v0", 2, 0},
  1456.   {"v1", 3, 0},
  1457.   {"zero", 0, 0}
  1458. };
  1459.  
  1460.  
  1461. int register_name_to_number (const char *name)
  1462. {
  1463.   register int c1 = *name, c2 = *(name + 1);
  1464.  
  1465.   if ('0' <= c1 && c1 <= '9'
  1466.       && (c2 == '\0' || (('0' <= c2 && c2 <= '9') && *(name + 2) == '\0')))
  1467.     return (atoi (name));
  1468.   else if (c1 == 'f' && c2 >= '0' && c2 <= '9')
  1469.     return atoi (name + 1);
  1470.   else
  1471.     {
  1472.       inst_info *entry =
  1473.     map_string_to_inst_info (register_tbl,
  1474.                  sizeof (register_tbl) / sizeof (inst_info),
  1475.                  name);
  1476.       if (entry == NULL)
  1477.     return (-1);
  1478.       else
  1479.     return (entry->value1);
  1480.     }
  1481. }
  1482.  
  1483.